<template><view>
<view class="top"><uni-search-bar class="sbg" bgColor="#FFFFFF" @confirm="so" :radius="100"></uni-search-bar>
</view><view class="top-pd"></view>
<block v-if="top_array.length>0">
<block v-for="top_item in top_array" :key="top_item.en">
<navigator :url="top_item.url" class="uni_tags c b">
{{top_item.en}}
<view>{{top_item.title}}</view>
</navigator>
</block>
</block>

<block v-if="ht_data.length>0">
<view class="b p10">文章推荐</view>
<block v-for="(newsitem, index2) in ht_data" :key="index2">
<media-item :newitem="newsitem"></media-item>
<yad v-if="index2%8==4" mode="feed"></yad>
</block>
<navigator url="/pages/ht/index" class="b p10 c">MORE<br>查看更多</navigator>
</block>
<block v-if="www_data.length>0">
<view class="b p10">本地信息</view>
<block v-for="(newsitem, index2) in www_data" :key="newsitem.id">
<mediaItem2 :lc="lc" :newitem="newsitem"></mediaItem2>
<yad v-if="index2%8==4" mode="feed"></yad>
</block>
<navigator url="/pages/www/index" class="b p10 c">MORE<br>查看更多</navigator>
</block>
<block v-if="pic_data.length>0">
<view class="b p10">图片墙</view>
<block v-for="(item, index) in pic_data" :key="item['id']">
<navigator :url="'/pageb/pic/t?id='+item['id']" class="p10 inline_img">
<image style="width:170upx;height:170upx;" mode="aspectFill" lazy-load="true" :data-src="imgswt+item.hash+'.'+item.ext" :src="imgswt+item.hash+'.'+item.ext"></image></navigator>
</block>
<yad mode="feed"></yad>
</block>


<pagestatus v-if="status.code !=200" :status="status" 
v-on:btnclick="getdata"
></pagestatus>

<view class="foot-pd"></view>

<view class="xfdiv" @click="top">三</view>
<view class="foot" v-if="foot_array"><view class="row"><view class="col b c">

<block v-for="foot_item in foot_array" :key="foot_item.en">

<navigator open-type="redirect" v-if="foot_item.en=='HOME'" :class="foot_class+' red'" :url="foot_item.url">
{{foot_item.en}}<view>{{foot_item.title}}</view></navigator>

<navigator v-else :class="foot_class" :url="foot_item.url">{{foot_item.en}}<view>{{foot_item.title}}</view></navigator>

</block>

</view></view></view>
</view></template>

<script>
	var __self=false;/*this的优化 */
import mediaItem2 from '@/components/list_www.vue';
	import mediaItem from '@/components/list.vue';
	import yad from '@/components/yad.vue'
	import pagestatus from '@/components/page-status.vue'
	export default {
components: {
mediaItem,mediaItem2,yad,pagestatus
},data() {
return {
	lc:getApp().globalData.ysv8set.lc,
Weizhan:false,
ht_data:false,
pic_data:false,
www_data:false,
foot_array:[],
top_array:[],
foot_class:'col_3',
imgswt:getApp().globalData.ysv8set.imgswt,
status:{
loading:true,
icon:'content',
title:'页面加载中...',
desc:'长时间无反应请点重新加载',
showBtn:true,
btnText:'重新加载',
code:400},
}},onShareAppMessage() {
return {
title: getApp().globalData.ysv8set.title,
content: getApp().globalData.ysv8set.description,
path: 'pages/index/index',
imageUrl: getApp().globalData.ysv8set.img
}},onLoad(e) {
__self=this;
if(e.lc){
getApp().globalData.ysv8set.lc=e.lc
this.lc=getApp().globalData.ysv8set.lc	
}
this.getdata()
},methods: {
getdata(){
uni.request({method:"GET",
cloudCache:getApp().globalData.ysv8set.cloudCache,

url:getApp().globalData.ysv8set.www+"index/index.api",data:{},
success:function(e){
/*自动设置底部导航*/
let foot_array=[{
title:'首页',
en:'HOME',
url:'/pages/index/index'
}];
if(getApp().globalData.ysv8set.isArray(e.data.ht_data)){
    foot_array.push({
        title:'文章',
        en:'ART',
        url:'/pages/ht/index'
    })
}
if(getApp().globalData.ysv8set.isArray(e.data.www_data)){
    foot_array.push({
        title:'本地',
        en:'LOC',
        url:'/pages/www/index'
    })
if(getApp().globalData.ysv8set.lc==false && !getApp().globalData.lcbool){
getApp().globalData.lcbool=true;
uni.getLocation({
success: function (res) {
getApp().globalData.ysv8set.lc=getApp().globalData.ysv8set.formatLocation(res.longitude, res.latitude);  
__self.lc=getApp().globalData.ysv8set.lc
uni.showToast({ title: '位置已更新'});
},fail:function(){
uni.redirectTo({
url: '/pagea/lcxz/lcxz?url='+encodeURIComponent('/pages/index/index?')
});
}});
}
}
if(getApp().globalData.ysv8set.isArray(e.data.zh_data)){
    foot_array.push({
        title:'动态',
        en:'MBL',
        url:'/pageb/zh/index'
    })
}
if(getApp().globalData.ysv8set.isArray(e.data.pic_data)){
    foot_array.push({
        title:'图片',
        en:'PIC',
        url:'/pageb/pic/index'
    })
}
if(e.data.Weizhan.wyq_num>0){
	if(foot_array.length>4)
	__self.top_array.push({
	    title:'微友圈',
	    en:'LMBL',
	    url:'/pageb/wyq/index'
	})
	else
	foot_array.push({
	    title:'微友圈',
	    en:'LMBL',
	    url:'/pageb/wyq/index'
	})
}
if(e.data.Weizhan.shop_num>0){
	if(foot_array.length>4)
	__self.top_array.push({
	    title:'店铺',
	    en:'SHOP',
	    url:'/pageb/shop/index'
	})
	else
	foot_array.push({
	    title:'店铺',
	    en:'SHOP',
	    url:'/pageb/shop/index'
	})
}
if(e.data.Weizhan.video_num>0){
	if(foot_array.length>4)
	__self.top_array.push({
	    title:'视频',
	    en:'VIDEO',
	    url:'/pageb/v/index'
	})
	else
	foot_array.push({
	    title:'视频',
	    en:'VIDEO',
	    url:'/pageb/v/index'
	})
}
if(e.statusCode ==200){
__self.ht_data=e.data.ht_data,
__self.zh_data=e.data.zh_data,
__self.pic_data=e.data.pic_data,
__self.www_data=e.data.www_data,
__self.foot_array=foot_array
if(foot_array.length>4)
__self.foot_class='col_20';
else
__self.foot_class='col_'+12/foot_array.length

__self.Weizhan=e.data.Weizhan
__self.status={
title:'加载完成',
showBtn:false,
code:200
}
/*SEO优化 */
getApp().globalData.ysv8set.title=e.data.Weizhan.title2 +'_' +e.data.Weizhan.ps
getApp().globalData.ysv8set.keywords=e.data.Weizhan.keywords
getApp().globalData.ysv8set.description=e.data.Weizhan.description
getApp().globalData.ysv8set.img=getApp().globalData.ysv8set.imgcdn+e.data.Weizhan.img
}else{
__self.status={
title:'网络错误',
desc:'网络连接错误',
showBtn:true,
btnText:'重新加载',
code:400
 }

}

},fail:function(){
__self.status={
title:'网络错误',
desc:'网络连接错误',
showBtn:true,
btnText:'重新加载',
code:400
 }
}
});


},so(k){
    uni.navigateTo({url: '/pageb/s/index?q='+encodeURIComponent(k.value)});
},top(){
    uni.pageScrollTo({
        scrollTop: 0,
        duration: 300,

    });
    uni.showActionSheet({
        itemList: ["历史记录", "关于我们"],
        success: function(a) {
            if ("1" == a.tapIndex) {

                uni.navigateTo({url: '/pagea/about/index'});
            }else{
                uni.navigateTo({url: '/pagea/fav/fav'});

            }

        }
    })
}
		}
	}
</script>

<style>
.xfdiv{z-index:999;position:fixed;bottom:250upx;width:100upx;  line-height:100upx;background-color:#fbf8f9;text-align:center; right: 20upx; border-radius: 100upx;
	height: 100upx; overflow: hidden;border:thin solid #d9d7d3; font-weight: bold; color:green; font-size:60upx;
}
	
	
	
	
</style>
